package org.reservation.action;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.reservation.pojo.Food;
import org.reservation.pojo.FoodCar;
import org.reservation.pojo.Restaurant;
import org.reservation.service.FoodService;
import org.reservation.service.ResService;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class WorkFlowAction extends ActionSupport{
	ResService resService;
	FoodService foodService; 
    
	public String index() throws Exception {
		
		return SUCCESS;
	}
	public String fontIndex() throws Exception{
		
		List<Restaurant> resIndexList =resService.loadRes();
		List<Food> foodList = foodService.loadFood();
		List<Food> foodIndexList=new ArrayList<Food>();
		Food food=null;
		for(int i=0;i<foodList.size();i++){
			food=foodList.get(i);
			if("Y".equals(food.getFoodIsTop())){
				foodIndexList.add(food);
			}
		}
		Map session=ActionContext.getContext().getSession();
		session.put("resIndexList", resIndexList);	
		session.put("foodIndexList", foodIndexList);	

		return SUCCESS;
		
	}
	
	public void setResService(ResService resService) {
		this.resService = resService;
	}
	public void setFoodService(FoodService foodService) {
		this.foodService = foodService;
	}
	
}
